debug: debug_stream: log per-core utilization from idle thread load#10658
debug: debug_stream: log per-core utilization from idle thread load#10658lgirdwood merged 1 commit intothesofproject:mainfrom
Conversation
|
This is very convenient debug tool especially when running with DP modules (the existing infra to track LL scheduler load don't provide the full picture anymore). Available when building SOF with "-o app/debug_stream_overlay.conf" and CONFIG_SOF_DEBUG_STREAM_THREAD_INFO=y |
There was a problem hiding this comment.
Pull request overview
This PR enhances debug_stream thread reporting by adding a per-core CPU utilization info log derived from the Zephyr idle thread’s runtime stats, while keeping the existing per-thread debug log output.
Changes:
- Add
<string.h>include (needed for string utilities used in the file). - Emit a
LOG_INFline for threads whose name starts with"idle", reporting utilization as100% - idle_thread_cpu%.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (name && strncmp(name, "idle", 4) == 0) | ||
| LOG_INF("core %u utilization %u%%", ud->core, | ||
| 100U - tinfo->cpu_usage * 100U / 255); |
There was a problem hiding this comment.
The new utilization LOG_INF can print misleading 100% utilization when runtime stats are unavailable (e.g., CONFIG_THREAD_RUNTIME_STATS disabled, ud->stats_valid false, or k_thread_runtime_stats_get() fails and thread_info_cpu_utilization returns 0). Please guard this log on stats availability (and ideally on a distinct “cpu usage valid” result) so 0% idle isn’t conflated with “unknown” idle load.
| if (name && strncmp(name, "idle", 4) == 0) | |
| LOG_INF("core %u utilization %u%%", ud->core, | |
| 100U - tinfo->cpu_usage * 100U / 255); | |
| #ifdef CONFIG_THREAD_RUNTIME_STATS | |
| if (ud->stats_valid && name && strncmp(name, "idle", 4) == 0) { | |
| LOG_INF("core %u utilization %u%%", ud->core, | |
| 100U - tinfo->cpu_usage * 100U / 255); | |
| } | |
| #endif |
There was a problem hiding this comment.
This file is only compiled with CONFIG_SOF_DEBUG_STREAM_THREAD_INFO=y and if that is select, it selects CONFIG_THREAD_RUNTIME_STATS (sof/src/debug/debug_stream/Kconfig). So the above ifdef is not necessary.
lgirdwood
left a comment
There was a problem hiding this comment.
LGTM, can you respond to copilot. Thanks !
| tinfo->name, tinfo->stack_usage * 100U / 255, | ||
| tinfo->cpu_usage * 100U / 255); | ||
|
|
||
| if (name && strncmp(name, "idle", 4) == 0) |
There was a problem hiding this comment.
That a kernel internal API it seems. Implemented a different option using .is_idle. For some reason only available with CONFIG_SMP, but I guess we can live with that.
|
|
||
| if (name && strncmp(name, "idle", 4) == 0) | ||
| LOG_INF("core %u utilization %u%%", ud->core, | ||
| 100U - tinfo->cpu_usage * 100U / 255); |
There was a problem hiding this comment.
why do we need a print? The debug-stream dump already shows how much the idle thread consumes, I'd think if we enable the debug stream, we want to see the information exactly there - in the debug stream, not in the log?
There was a problem hiding this comment.
@lyakh That's a fair question. My problem: I want to see CPU utilization during testing and I don't want to run deug_stream python client as that busyloops on the SRAM window (versus mtrace that uses interrupts to wake-up host to read). With DP modules added, our old CPU load mechamisms (that print LL load to mtrace) don't work anymore, so I need something more.
@jsarha What do you think? Should I make this optional? Or just keep on my personal branch?
There was a problem hiding this comment.
If its on a personal branch then its useful. Pls keep it.
Keep the per-thread stack and cpu LOG_DBG print and add a separate LOG_INF that fires only for the Zephyr idle thread. The info-level print reports per-core CPU utilization calculated as the inverse of the idle thread load percentage. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
e2baaaf to
292e165
Compare
|
V2:
|
Keep the per-thread stack and cpu LOG_DBG print and add a separate LOG_INF that fires only for the Zephyr idle thread. The info-level print reports per-core CPU utilization calculated as the inverse of the idle thread load percentage.